import { FC } from 'react'
import { Typography } from 'antd'
import PropComponent from './PropComponent'
const { Paragraph } = Typography
export type propsType = {
  text?: string
  isCenter?: boolean
  disabled?: boolean
}
const questionParagraph: FC<propsType> = props => {
  const { text = '一行段落', isCenter = false } = props
  // const t = text.replaceAll('\n', '<br/>')  不安全
  return (
    <Paragraph style={{ textAlign: isCenter ? 'center' : 'start', marginBottom: '0' }}>
      {/* <span dangerouslySetInnerHTML={{ __html: t }}></span> 不安全 */}
      {text.split('\n').map((item, index) => (
        <span key={index}>
          {item}
          <br />
        </span>
      ))}
    </Paragraph>
  )
}

export const questionParagraphConfig = {
  title: '段落',
  type: 'questionParagraph',
  PropComponent,
  Component: questionParagraph,
}

export default questionParagraph
